package com.sjc.designpattern.singleton;

import java.util.concurrent.atomic.AtomicLong;

/**
 * @Classname EnumSingletonPatternDemo
 * @Description 枚举
 * 通过 Java 枚举类型本身的特性，保证了实例创建的线程安全性和实例的唯一性
 * @Date 2020/5/3 10:35
 * @Created by SangJiacun
 */
public enum EnumSingletonPatternDemo {
    INSTANCE;

    private AtomicLong id = new AtomicLong(0);

    public long getId(){
        return id.incrementAndGet();
    }
}
